package com.uni.common.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.uni.common.util.SystemConfig;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户消息
 * @author yuyanzheng
 *
 */
@NoArgsConstructor
@Data
public class Message {
	private Long id;
	private Long userId;
	private Integer type;
	private Long sourceId;
	private String content;
	private int read;
	@JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
	private Date updateTime;

	@JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
	private Date createTime;

	private Long fromUserId;
	private String fromUserName;
	private String userName;
	private String fromUserImg;
	private String fromImg;
	private String fromContent ;
	@JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
	private Date actionTime;





	public String getFromUserImgAll() {
		if(fromUserImg != null && !"".equals(fromUserImg) && !fromUserImg.startsWith("http")) {
			return SystemConfig.basePath + fromUserImg;
		}
		return fromUserImg;
	}

	public List<String> getPicsAll() {

		String[] split = fromImg.split(",");
		List<String> list=new ArrayList<String>();

		for (int i=0;i<split.length;i++){
			if(split[i] != null && !"".equals(split[i]) && !split[i].startsWith("http")) {
				list.add(SystemConfig.basePath + split[i]) ;
			}
			continue;
		}
		return list;
	}
//	private Long fromUserId;
//	private String fromUserProfilePhoto;
//	private String title;
//	private String content;
//	private String orderNo;
//	private double price;
//	private Integer priceType;
//	private String ext;
//	private Integer type;
//	private Integer status;
//	private Integer deleted;

}
